package com.yoda.mall.admin.controller;

import com.yoda.mall.admin.service.SubjectService;
import com.yoda.mall.model.entity.cms.Subject;
import com.yoda.mall.model.entity.pms.Product;
import com.yoda.mall.model.vo.PageResult;
import com.yoda.mall.model.vo.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author shawn
 * @date 2022年 12月 17日 11:33
 */
@RestController
@RequestMapping("/subject")
public class SubjectController {

    @Resource
    private SubjectService subjectService;

    @GetMapping("/list")
    public R subjectList(String keyword, @RequestParam(defaultValue = "1") Integer pageNum,
                         @RequestParam(defaultValue = "5") Integer pageSize) {
        PageResult<Subject> pageResult = subjectService.selectByPage(keyword, pageNum, pageSize);
        return R.success(pageResult);
    }

    /**
     * 获取全部商品专题
     * @return
     */
    @GetMapping("/listAll")
    public R subjectArr() {
        List<Subject> subjectList = subjectService.subjectArr();
        return R.success(subjectList);
    }

}
